package com.babyqiao.wallpaper.portal.utils.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.redisson.config.TransportMode;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;

/**
 * @author QLZ
 * @date 2021/2/24
 */
@Configuration
public class RedissonConfig {
    @Value("${redisson.addr}")
    private  String addr;
    @Value("${spring.redis.password}")
    private String password;
    @Bean(destroyMethod="shutdown")
    public RedissonClient redisson() throws IOException {
        Config config = new Config();
        config.useSingleServer().setAddress(addr).setPassword(password);


        //根据config创建出实例
        RedissonClient redissonClient=Redisson.create(config);
        return redissonClient;
    }
}
